//
//  RSDatePickerViewController.m
//  StaffTax
//
//  Created by 侯伟 on 2020/1/3.
//  Copyright © 2020 侯伟. All rights reserved.
//

#import "RSDatePickerViewController.h"

#import <MyLayout.h>

#define MAXYEAR 2099
#define MINYEAR 1900

@interface RSDatePickerViewController ()<UIPickerViewDelegate,UIPickerViewDataSource,UIGestureRecognizerDelegate> {
    //日期存储数组
    NSMutableArray *_yearArray;
    NSMutableArray *_monthArray;
    NSMutableArray *_dayArray;
    NSMutableArray *_hourArray;
    NSMutableArray *_minuteArray;
    NSString *_dateFormatter;
    //记录位置
    NSInteger yearIndex;
    NSInteger monthIndex;
    NSInteger dayIndex;
    NSInteger hourIndex;
    NSInteger minuteIndex;
    
    NSInteger preRow;
    
    NSDate *_startDate;
}

/// 标题
@property (nonatomic,strong) UILabel *titleLb;

/// 时间选择器承载
@property (nonatomic,strong)MyFrameLayout *pickerView;

/// 时间选择器
@property (nonatomic,strong)UIPickerView *datePicker;



@end

@implementation RSDatePickerViewController

- (void)loadView{
    [super loadView];
    [self initViews];
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self getNowDate:self.currentDate animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self defaultConfig];
}

- (void)initViews{
    
    MyLinearLayout* popView = [[MyLinearLayout alloc] initWithOrientation:(MyOrientation_Vert)];
    popView.backgroundColor = UIColor.whiteColor;
    popView.myHorzMargin = 0;
    popView.myBottom = 0;
    popView.myHeight = MyLayoutSize.wrap;
    [self.view addSubview:popView];
    self.popView = popView;
    
    popView.endLayoutBlock = ^{
        [self.popView setCornerRadius:(UIRectCornerTopLeft|UIRectCornerTopRight) size:CGSizeMake(PX(12), PX(12))];
        self.popView.layer.masksToBounds = YES;
    };
    
    MyLinearLayout* titleLayout = [[MyLinearLayout alloc] initWithOrientation:(MyOrientation_Horz)];
    titleLayout.padding = UIEdgeInsetsMake(0, 0, 0, 0);
    titleLayout.myHeight = PX(60.0);
    titleLayout.myMargin = 0;
    [popView addSubview:titleLayout];
    
    MyBorderline* line = [MyBorderline new];
    line.color = COLOR_GRAY_LINE;
    line.thick = 1.0;
    titleLayout.bottomBorderline = line;
    
    
    UIButton* cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:HEXCOLOR(0x727E8C) forState:UIControlStateNormal];
    cancelBtn.titleLabel.font = FONT_FIT(14);
    [cancelBtn addTarget:self action:@selector(cancelSelect:) forControlEvents:UIControlEventTouchUpInside];
    cancelBtn.mySize = CGSizeMake(70, 32);
    cancelBtn.myCenterY = 0;
    cancelBtn.myLeft = 0;
    [titleLayout addSubview:cancelBtn];
    
    UILabel* titleLb = [UILabel lableWithFont:FONT_FIT(16) color:COLOR_BLACK_DARK text:NULL];
    titleLb.textAlignment = NSTextAlignmentCenter;
    titleLb.myHorzMargin = 15.0;
    titleLb.myCenterY = 0;
    titleLb.weight = 1.0;
    [titleLayout addSubview:titleLb];
    _titleLb = titleLb;
    _titleLb.text = self.titleStr;
    [_titleLb sizeToFit];
    
    UIButton* sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [sureBtn setTitle:@"确定" forState:UIControlStateNormal];
    [sureBtn setTitleColor:COLOR_THEME forState:UIControlStateNormal];
    sureBtn.titleLabel.font = FONT_FIT(14);
    [sureBtn addTarget:self action:@selector(doneObject:) forControlEvents:UIControlEventTouchUpInside];
    sureBtn.mySize = CGSizeMake(70, 32);
    sureBtn.myCenterY = 0;
    sureBtn.myRight = 0;
    [titleLayout addSubview:sureBtn];
    
    
    MyFrameLayout* pickerView = [MyFrameLayout new];
    pickerView.myHeight = PX(275.0);
    pickerView.myMargin = 0;
    [popView addSubview:pickerView];
    _pickerView = pickerView;
    
    
    UIPickerView* picker = [UIPickerView new];
    picker.dataSource = self;
    picker.delegate = self;
    picker.myMargin = 0;
    [pickerView addSubview:picker];
    _datePicker = picker;
    
}

-(void)defaultConfig {
    
    if (!_currentDate) {
        _currentDate = [NSDate date];
    }
    //最大最小限制
    if (!self.maxLimitDate) {
        self.maxLimitDate = [NSDate dateWithYear:2099 month:12 day:31 hour:23 minute:59 second:59];
    }
    //最小限制
    if (!self.minLimitDate) {
        self.minLimitDate = [NSDate dateWithYear:1900 month:1 day:1 hour:0 minute:0 second:0];
    }
    
    switch (self.dateStyle) {
        case DateStyleShowYearMonthDayHourMinute:
            _dateFormatter = @"yyyy-MM-dd HH:mm";
            break;
        case DateStyleShowMonthDayHourMinute:
            _dateFormatter = @"yyyy-MM-dd HH:mm";
            break;
        case DateStyleShowYearMonthDay:
            _dateFormatter = @"yyyy-MM-dd";
            break;
        case DateStyleShowYearMonth:
            _dateFormatter = @"yyyy-MM";
            break;
        case DateStyleShowMonthDay:
            _dateFormatter = @"yyyy-MM-dd";
            break;
        case DateStyleShowHourMinute:
            _dateFormatter = @"HH:mm";
            break;
        case DateStyleShowYear:
            _dateFormatter = @"yyyy";
            break;
        case DateStyleShowMonth:
            _dateFormatter = @"MM";
            break;
        case DateStyleShowDayHourMinute:
            _dateFormatter = @"dd HH:mm";
            break;
        default:
            _dateFormatter = @"yyyy-MM-dd HH:mm";
            break;
    }
    //循环滚动时需要用到
    preRow = (self.currentDate.year - MINYEAR) * 12 + self.currentDate.month - 1;
    
    //设置年月日时分数据
    _yearArray = [self setArray:_yearArray];
    _monthArray = [self setArray:_monthArray];
    _dayArray = [self setArray:_dayArray];
    _hourArray = [self setArray:_hourArray];
    _minuteArray = [self setArray:_minuteArray];
    
    for (int i=0; i<60; i++) {
        NSString *num = [NSString stringWithFormat:@"%02d",i];
        if (0<i && i<=12)
            [_monthArray addObject:num];
        if (i<24)
            [_hourArray addObject:num];
        [_minuteArray addObject:num];
    }
    for (NSInteger i = MINYEAR; i <= MAXYEAR; i++) {
        NSString *num = [NSString stringWithFormat:@"%ld",(long)i];
        [_yearArray addObject:num];
    }
    
    if (!_dateLabelColor) {
        _dateLabelColor = COLOR_BLACK_DARK;
    }
    
    if (!_datePickerColor) {
        _datePickerColor = COLOR_BLACK_DARK;
    }
}

- (NSMutableArray *)setArray:(id)mutableArray{
    if (mutableArray)
        [mutableArray removeAllObjects];
    else
        mutableArray = [NSMutableArray array];
    return mutableArray;
}



-(void)addLabelWithName:(NSArray *)nameArr {
    for (id subView in self.pickerView.subviews) {
        if ([subView isKindOfClass:[UILabel class]]) {
            [subView removeFromSuperview];
        }
    }
    
    for (int i=0; i<nameArr.count; i++) {
        CGFloat labelX = CGRectGetWidth(self.datePicker.frame)/(nameArr.count*2)+18+CGRectGetWidth(self.datePicker.frame)/nameArr.count*i;
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(labelX, self.pickerView.frame.size.height/2-15/2.0, 15, 15)];
        label.text = nameArr[i];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = FONT_FIT(15);
        label.textColor =  _dateLabelColor;
        label.myLeft = labelX;
        label.myCenterY = 0;
        label.backgroundColor = [UIColor clearColor];
    
        [self.pickerView addSubview:label];
    }
}

#pragma mark - UIPickerViewDelegate,UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    switch (self.dateStyle) {
        case DateStyleShowYearMonthDayHourMinute:
            [self addLabelWithName:@[@"年",@"月",@"日",@"时",@"分"]];
            return 5;
        case DateStyleShowMonthDayHourMinute:
            [self addLabelWithName:@[@"月",@"日",@"时",@"分"]];
            return 4;
        case DateStyleShowYearMonthDay:
            [self addLabelWithName:@[@"年",@"月",@"日"]];
            return 3;
        case DateStyleShowYearMonth:
            [self addLabelWithName:@[@"年",@"月"]];
            return 2;
        case DateStyleShowMonthDay:
            [self addLabelWithName:@[@"月",@"日"]];
            return 2;
        case DateStyleShowHourMinute:
            [self addLabelWithName:@[@"时",@"分"]];
            return 2;
        case DateStyleShowYear:
            [self addLabelWithName:@[@"年"]];
            return 1;
        case DateStyleShowMonth:
            [self addLabelWithName:@[@"月"]];
            return 1;
        case DateStyleShowDayHourMinute:
            [self addLabelWithName:@[@"日",@"时",@"分"]];
            return 3;
        default:
            return 0;
    }
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    NSArray *numberArr = [self getNumberOfRowsInComponent];
    return [numberArr[component] integerValue];
}

-(NSArray *)getNumberOfRowsInComponent {
    
    NSInteger yearNum = _yearArray.count;
    NSInteger monthNum = _monthArray.count;
    NSInteger dayNum = [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
    
    NSInteger dayNum2 = [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:1];//确保可以选到31日
    
    NSInteger hourNum = _hourArray.count;
    NSInteger minuteNUm = _minuteArray.count;
    
    NSInteger timeInterval = MAXYEAR - MINYEAR;
    
    switch (self.dateStyle) {
        case DateStyleShowYearMonthDayHourMinute:
            return @[@(yearNum),@(monthNum),@(dayNum),@(hourNum),@(minuteNUm)];
            break;
        case DateStyleShowMonthDayHourMinute:
            return @[@(monthNum*timeInterval),@(dayNum),@(hourNum),@(minuteNUm)];
            break;
        case DateStyleShowYearMonthDay:
            return @[@(yearNum),@(monthNum),@(dayNum)];
            break;
        case DateStyleShowYearMonth:
            return @[@(yearNum),@(monthNum)];
            break;
        case DateStyleShowMonthDay:
            return @[@(monthNum*timeInterval),@(dayNum),@(hourNum)];
            break;
        case DateStyleShowHourMinute:
            return @[@(hourNum),@(minuteNUm)];
            break;
        case DateStyleShowYear:
            return @[@(yearNum)];
            break;
        case DateStyleShowMonth:
            return @[@(monthNum)];
            break;
        case DateStyleShowDayHourMinute:
            return @[@(dayNum2),@(hourNum),@(minuteNUm)];
            break;
        default:
            return @[];
            break;
    }
    
}

-(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
    return PX(55.0);
}


-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
    UILabel *customLabel = (UILabel *)view;
    if (!customLabel) {
        customLabel = [[UILabel alloc] init];
        customLabel.textAlignment = NSTextAlignmentCenter;
        [customLabel setFont:FONT_FIT(15)];
    }
    NSString *title;
    
    switch (self.dateStyle) {
        case DateStyleShowYearMonthDayHourMinute:
            if (component==0) {
                title = _yearArray[row];
            }
            if (component==1) {
                title = _monthArray[row];
            }
            if (component==2) {
                title = _dayArray[row];
            }
            if (component==3) {
                title = _hourArray[row];
            }
            if (component==4) {
                title = _minuteArray[row];
            }
            break;
        case DateStyleShowYearMonthDay:
            if (component==0) {
                title = _yearArray[row];
            }
            if (component==1) {
                title = _monthArray[row];
            }
            if (component==2) {
                title = _dayArray[row];
            }
            break;
        case DateStyleShowYearMonth:
            if (component==0) {
                title = _yearArray[row];
            }
            if (component==1) {
                title = _monthArray[row];
            }
            break;
        case DateStyleShowMonthDayHourMinute:
            if (component==0) {
                title = _monthArray[row%12];
            }
            if (component==1) {
                title = _dayArray[row];
            }
            if (component==2) {
                title = _hourArray[row];
            }
            if (component==3) {
                title = _minuteArray[row];
            }
            break;
        case DateStyleShowMonthDay:
            if (component==0) {
                title = _monthArray[row%12];
            }
            if (component==1) {
                title = _dayArray[row];
            }
            break;
        case DateStyleShowHourMinute:
            if (component==0) {
                title = _hourArray[row];
            }
            if (component==1) {
                title = _minuteArray[row];
            }
            break;
        case DateStyleShowYear:
            if (component==0) {
                title = _yearArray[row];
            }
            break;
        case DateStyleShowMonth:
            if (component==0) {
                title = _monthArray[row];
            }
            break;
        case DateStyleShowDayHourMinute:
            if (component==0) {
                title = _dayArray[row];
            }
            if (component==1) {
                title = _hourArray[row];
            }
            if (component==2) {
                title = _minuteArray[row];
            }
            break;
        default:
            title = @"";
            break;
    }
    
    customLabel.text = title;
    customLabel.textColor = _datePickerColor;
    return customLabel;
    
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    
    switch (self.dateStyle) {
        case DateStyleShowYearMonthDayHourMinute:{
            if (component == 0) {
                yearIndex = row;
            }
            if (component == 1) {
                monthIndex = row;
            }
            if (component == 2) {
                dayIndex = row;
            }
            if (component == 3) {
                hourIndex = row;
            }
            if (component == 4) {
                minuteIndex = row;
            }
            if (component == 0 || component == 1){
                [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
                if (_dayArray.count-1<dayIndex) {
                    dayIndex = _dayArray.count-1;
                }
            }
        }
            break;
        case DateStyleShowYearMonthDay:{
            if (component == 0) {
                yearIndex = row;
            }
            if (component == 1) {
                monthIndex = row;
            }
            if (component == 2) {
                dayIndex = row;
            }
            if (component == 0 || component == 1){
                [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
                if (_dayArray.count-1<dayIndex) {
                    dayIndex = _dayArray.count-1;
                }
            }
        }
            break;
        case DateStyleShowYearMonth:{
            if (component == 0) {
                yearIndex = row;
            }
            if (component == 1) {
                monthIndex = row;
            }
        }
            break;
        case DateStyleShowMonthDayHourMinute:{
            if (component == 1) {
                dayIndex = row;
            }
            if (component == 2) {
                hourIndex = row;
            }
            if (component == 3) {
                minuteIndex = row;
            }
            if (component == 0) {
                [self yearChange:row];
                [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
                if (_dayArray.count-1<dayIndex) {
                    dayIndex = _dayArray.count-1;
                }
            }
            [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
            
        }
            break;
        case DateStyleShowMonthDay:{
            if (component == 1) {
                dayIndex = row;
            }
            if (component == 0) {
                [self yearChange:row];
                [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
                if (_dayArray.count-1<dayIndex) {
                    dayIndex = _dayArray.count-1;
                }
            }
            [self DaysfromYear:[_yearArray[yearIndex] integerValue] andMonth:[_monthArray[monthIndex] integerValue]];
        }
            break;
        case DateStyleShowHourMinute:{
            if (component == 0) {
                hourIndex = row;
            }
            if (component == 1) {
                minuteIndex = row;
            }
        }
            break;
        case DateStyleShowYear:{
            if (component == 0) {
                yearIndex = row;
            }
        }
            break;
        case DateStyleShowMonth:{
            if (component == 0) {
                monthIndex = row;
            }
        }
            break;
        case DateStyleShowDayHourMinute:{
            if (component == 0) {
                dayIndex = row;
            }
            if (component == 1) {
                hourIndex = row;
            }
            if (component == 2) {
                minuteIndex = row;
            }
        }
            break;
        default:
            break;
    }
    
    [pickerView reloadAllComponents];
    
    NSString *dateStr = [NSString stringWithFormat:@"%@-%@-%@ %@:%@",_yearArray[yearIndex],_monthArray[monthIndex],_dayArray[dayIndex],_hourArray[hourIndex],_minuteArray[minuteIndex]];
    switch (self.dateStyle) {
        case DateStyleShowYearMonthDay:
            dateStr = [NSString stringWithFormat:@"%@-%@-%@",_yearArray[yearIndex],_monthArray[monthIndex],_dayArray[dayIndex]];
            break;
        case DateStyleShowYearMonth:
            dateStr = [NSString stringWithFormat:@"%@-%@",_yearArray[yearIndex],_monthArray[monthIndex]];
            break;
        case DateStyleShowMonthDay:
            dateStr = [NSString stringWithFormat:@"%@-%@-%@",_yearArray[yearIndex],_monthArray[monthIndex],_dayArray[dayIndex]];
            break;
        case DateStyleShowHourMinute:
            dateStr = [NSString stringWithFormat:@"%@:%@",_hourArray[hourIndex],_minuteArray[minuteIndex]];
            break;
        case DateStyleShowYear:
            dateStr = [NSString stringWithFormat:@"%@",_yearArray[yearIndex]];

            break;
        case DateStyleShowMonth:
            dateStr = [NSString stringWithFormat:@"%@",_monthArray[monthIndex]];

            break;
        case DateStyleShowDayHourMinute:
            dateStr = [NSString stringWithFormat:@"%@ %@:%@",_dayArray[dayIndex],_hourArray[hourIndex],_minuteArray[minuteIndex]];

            break;
        default:
            dateStr = [NSString stringWithFormat:@"%@-%@-%@ %@:%@",_yearArray[yearIndex],_monthArray[monthIndex],_dayArray[dayIndex],_hourArray[hourIndex],_minuteArray[minuteIndex]];
            break;
    }

    
    self.currentDate = [NSDate dateFromString:dateStr withFormat:_dateFormatter];
    
    if ([self.currentDate compare:self.minLimitDate] == NSOrderedAscending) {
        self.currentDate = self.minLimitDate;
        [self getNowDate:self.minLimitDate animated:YES];
    }else if ([self.currentDate compare:self.maxLimitDate] == NSOrderedDescending){
        self.currentDate = self.maxLimitDate;
        [self getNowDate:self.maxLimitDate animated:YES];
    }
    
    _startDate = self.currentDate;
    
}

-(void)yearChange:(NSInteger)row {
    
    monthIndex = row%12;
    
    //年份状态变化
    if (row-preRow <12 && row-preRow>0 && [_monthArray[monthIndex] integerValue] < [_monthArray[preRow%12] integerValue]) {
        yearIndex ++;
    } else if(preRow-row <12 && preRow-row > 0 && [_monthArray[monthIndex] integerValue] > [_monthArray[preRow%12] integerValue]) {
        yearIndex --;
    }else {
        NSInteger interval = (row-preRow)/12;
        yearIndex += interval;
    }
    
    preRow = row;
}

#pragma mark - tools
//通过年月求每月天数
- (NSInteger)DaysfromYear:(NSInteger)year andMonth:(NSInteger)month
{
    NSInteger num_year  = year;
    NSInteger num_month = month;
    
    BOOL isrunNian = num_year%4==0 ? (num_year%100==0? (num_year%400==0?YES:NO):YES):NO;
    switch (num_month) {
        case 1:case 3:case 5:case 7:case 8:case 10:case 12:{
            [self setdayArray:31];
            return 31;
        }
        case 4:case 6:case 9:case 11:{
            [self setdayArray:30];
            return 30;
        }
        case 2:{
            if (isrunNian) {
                [self setdayArray:29];
                return 29;
            }else{
                [self setdayArray:28];
                return 28;
            }
        }
        default:
            break;
    }
    return 0;
}

//设置每月的天数数组
- (void)setdayArray:(NSInteger)num
{
    [_dayArray removeAllObjects];
    for (int i=1; i<=num; i++) {
        [_dayArray addObject:[NSString stringWithFormat:@"%02d",i]];
    }
}

//滚动到指定的时间位置
- (void)getNowDate:(NSDate *)date animated:(BOOL)animated
{
    if (!date) {
        date = [NSDate date];
    }
    
    [self DaysfromYear:date.year andMonth:date.month];
    
    yearIndex = date.year-MINYEAR;
    monthIndex = date.month-1;
    dayIndex = date.day-1;
    hourIndex = date.hour;
    minuteIndex = date.minute;
    
    //循环滚动时需要用到
    preRow = (self.currentDate.year-MINYEAR)*12+self.currentDate.month-1;
    
    NSArray *indexArray;
    
    if (self.dateStyle == DateStyleShowYearMonthDayHourMinute)
        indexArray = @[@(yearIndex),@(monthIndex),@(dayIndex),@(hourIndex),@(minuteIndex)];
    if (self.dateStyle == DateStyleShowYearMonthDay)
        indexArray = @[@(yearIndex),@(monthIndex),@(dayIndex)];
    if (self.dateStyle == DateStyleShowYearMonth)
        indexArray = @[@(yearIndex),@(monthIndex)];
    if (self.dateStyle == DateStyleShowMonthDayHourMinute)
        indexArray = @[@(monthIndex),@(dayIndex),@(hourIndex),@(minuteIndex)];
    if (self.dateStyle == DateStyleShowMonthDay)
        indexArray = @[@(monthIndex),@(dayIndex)];
    if (self.dateStyle == DateStyleShowHourMinute)
        indexArray = @[@(hourIndex),@(minuteIndex)];
    if (self.dateStyle == DateStyleShowYear)
        indexArray = @[@(yearIndex)];
    if (self.dateStyle == DateStyleShowMonth)
        indexArray = @[@(monthIndex)];
    if (self.dateStyle == DateStyleShowDayHourMinute)
        indexArray = @[@(dayIndex),@(hourIndex),@(minuteIndex)];
    
    [self.datePicker reloadAllComponents];
    
    for (int i=0; i<indexArray.count; i++) {
        if ((self.dateStyle == DateStyleShowMonthDayHourMinute || self.dateStyle == DateStyleShowMonthDay)&& i==0) {
            NSInteger mIndex = [indexArray[i] integerValue]+(12*(self.currentDate.year - MINYEAR));
            [self.datePicker selectRow:mIndex inComponent:i animated:animated];
        } else {
            [self.datePicker selectRow:[indexArray[i] integerValue] inComponent:i animated:animated];
        }
        
    }
}

#pragma mark -action

- (void)doneObject:(UIButton *)sender {
    
    NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    fmt.dateFormat = _dateFormatter;
    NSString *selfStr = [fmt stringFromDate:self.currentDate];

    _startDate = [fmt dateFromString:selfStr];
    if(self.doneBlock){
        self.doneBlock(self->_startDate);
    }
    
    [self dismissActionSheetController:^{
    }];
}


- (void)cancelSelect:(UIButton *)sender {
    [self dismissActionSheetController:NULL];
}

@end
